import { Component, OnInit, Injector, ViewChild, EventEmitter, Output } from '@angular/core';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { AppComponentBase } from '@shared/common/app-component-base';
import {
    StockZT_OutBillItemServiceProxy
} from '@shared/service-proxies/stock-service-proxies';
import * as _ from 'lodash';
import { ModalDirective } from 'ngx-bootstrap';
import { Base_UserCardServiceProxy } from '@shared/service-proxies/stock-service-proxies';

@Component({
    templateUrl: './user-card-modal.component.html',
    animations: [appModuleAnimation()],
    selector: 'userCardModal'
})
export class UserCardModalComponent extends AppComponentBase   {
    constructor(
        injector: Injector,
        private _base_UserCardServiceProxy:  Base_UserCardServiceProxy
    ) {
        super(injector);
    }

    @ViewChild('createOrEditModal') modal: ModalDirective;

    @Output() modalSave: EventEmitter<any> = new EventEmitter<any>();
   
 
    saving = false;
    closed = false;
    active = false;
    userName='';
    cardno='';
        show(billid?:string): void {
      //  this.active = true;
        this.closed = false;
        this.modal.show();

    }

    close(): void {
      //  this.active = false;
        this.modal.hide();
    }

    onHidden(event) {
        this.closed = true;
    }


    save() {
       this._base_UserCardServiceProxy.getUserInfoByCardNo(this.cardno).subscribe(result=>{
        if(result.realName==null||result.realName==undefined)
        {
            this.notify.error(this.l('未查询到用户信息！'));
            return;
        }
        else
        {
            this.userName=result.realName;
            this.modalSave.emit(result);
            this.close();
        }
       })
    }






}
